﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MyMainSite.Models.QuickBlogsModel>" ValidateRequest="false" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">

<script type="text/javascript">

    $(document).ready(function () {
        $("#blogId").change(function () {

            var id = $(this).attr("value");

            var entries = $.getJSON("/quick/blogentries/" + id, function (data) {

                var html = "";

                $.each(data, function (k, v) {

                    html += "<option value=\"" + v.Key + "\">" + v.Value + "</option>";
                });
                html += "<option value=\"0\">New...</option>";

                $("#entryId").html(html);
            });
        });

        $("#entryId").change(function () {

            var id = $(this).attr("value");

            var entry = $.getJSON("/quick/blogentry/" + id, function (data) {

                $("#textTitle").attr("value", data.Title);
                $("#textFriendlyUrl").attr("value", data.FriendlyUrl);
                $("#textDescription").attr("value", data.Description);
            });
        });
    });

</script>

<form action="/quick/blogs" method="post" enctype="multipart/form-data">

Projects: <select id="blogId" name="blogId">
    <% foreach(var b in Model.Blogs) { %>
        <option value="<%: b.BlogId %>"><%: b.Name %></option>
    <% } %>

</select>
<br />
Entries: <select id="entryId" name="entryId"></select>
<br />
<h2>Entry</h2>
Title: <input id="textTitle" name="textTitle" /><br />
Friendly Url: <input id="textFriendlyUrl" name="textFriendlyUrl" /><br />
Body: <textarea id="textDescription" name="textDescription" rows="6">&lt;p&gt;&lt;/p&gt;</textarea><br />
 
    <input type="submit" name="submit" value="Submit" />
</form>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="contentMainMenu" runat="server">
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="contentBreadCrumb" runat="server">
</asp:Content>

<asp:Content ID="Content4" ContentPlaceHolderID="contentLeftMenu" runat="server">
</asp:Content>
